﻿using System;
using System.Collections.Generic;

using Apache.Cassandra;

namespace RexToy.Cassandra.Meta
{
    internal class KeyspaceInfo
    {
        private KsDef _def;
        private Dictionary<string, ColumnFamilyInfo> _dicts;
        internal KeyspaceInfo(KsDef def)
        {
            def.ThrowIfNullArgument("def");
            _dicts = new Dictionary<string,ColumnFamilyInfo>();
            _def = def;            
            foreach(var cfDef in _def.Cf_defs)
            {
                _dicts.Add(cfDef.Name, new ColumnFamilyInfo(cfDef));
            }
        }

        public bool DurableWrites
        {
            get { return _def.Durable_writes; }
        }

        public string Name
        {
            get { return _def.Name; }
        }

        public int ReplicationFactor
        {
            get { return _def.Replication_factor; }
        }

        public string StrategyClass
        {
            get { return _def.Strategy_class; }
        }

        public IReadOnlyDictionary<string, string> Options
        {
            get { return _def.Strategy_options; }
        }

        public IReadOnlyDictionary<string, ColumnFamilyInfo> ColumnFamilyInfos
        {
            get { return _dicts; }
        }
    }
}
